package com.wangfugui.mybatisplus.utils;

import com.wangfugui.mybatisplus.domain.PortfolioInformation;

public class PortfolioFormatter {

    public static String format(PortfolioInformation info) {
        StringBuilder sb = new StringBuilder();

        appendLine(sb, "LongExposure多头敞口: ", info.getLongExposure());
        appendLine(sb, "ShortExposure空头敞口: ", info.getShortExposure());
        appendLine(sb, "GrossExposure总敞口: ", info.getGrossExposure());
        appendLine(sb, "NetExposure净敞口: ", info.getNetExposure());
        appendLine(sb, "ChangeInTotalMarketValue总市值变动: ", info.getChangeInTotalMarketValue());
        appendLine(sb, "AUMAsATPreviousMonthEnd上月底资产净值: ", info.getAUMAsATPreviousMonthEnd());
        appendLine(sb, "AUMAsAtPreviousDay前一日资产净值: ", info.getCICCAUMAsAtPreviousDay());
        appendLine(sb, "AUMAsAtReportDay当日资产净值: ", info.getCICCAUMAsAtReportDay());
//        appendLine(sb, "MTDSubscription当月至今认购金额", "0.00");
//        appendLine(sb, "MTDRedemption当月至今赎回金额", "0.00");
        appendLine(sb, "DailyReturn日回报率: ", info.getDailyReturn());
        appendLine(sb, "MTDReturn当月至今回报率: ", info.getMTDReturn());
        appendLine(sb, "YTDReturn年初至今回报率: ", info.getYTDReturn());
        appendLine(sb, "ITDReturn期初至今回报率: ", info.getITDReturn());
        return sb.toString();
    }

    private static void appendLine(StringBuilder sb, String label, String value) {
        sb.append(label).append("\t").append(value).append("\n");
    }

    private static void appendPercentage(StringBuilder sb, String label, String value) {
        if (value != null && !value.isEmpty()) {
            double percent = Double.parseDouble(value);
            sb.append(label).append("\t").append(String.format("%.2f%%", percent)).append("\n");
        } else {
            sb.append(label).append("\tN/A\n");
        }
    }
}